var express = require("express");
var router = express.Router();
var { userModel,coze } = require('../model/model');
router.get('/bjwusers',async (req,res)=>{
    const id=req.query.id
    let users = await userModel.find({_id:{$ne:id}})
    res.send({
        code:200,
        users: users
    })
})
router.post('/bjwlist',async (req,res)=>{
    const text=req.body
    coze.create(text)
    res.send({
        code:200,
    })
})
router.get('/bjwlist',async (req,res)=>{
    const lists=await coze.find()
    console.log(lists)
    res.send({
        code:200,
        lists:lists
    })
})
router.get('/bjwuser',async (req,res)=>{
    const id=req.query.id
    const li=[]
    let users = await userModel.find({_id:{$ne:id}})
    console.log(users)
    for(let i=0;i<users.length;i++){
        // li.push()
        const l=await userModel.find({_id:users[i]._id})
        li.push(l)
    }
    res.send({
        code:200,
        list:li
    })
})
module.exports = router;
